<script type="text/javascript">
DevMod.AddField();
</script>
<div class="block">
<h1>Add Dev Mod Assistent</h1>
{if !isset($sql)}
<h2>Tabellen Definition</h2>
<form action="#" onsubmit="BkLoader.Post(this).Load('mysql_mgr'); return false;" method="post">
<table class="form_table">
	<tr>
		<td>Tabellen Name</td>
		<td valign="top" width="220" rowspan="5"><div class="tip" style="margin-right:10px;">
		Tipp: Das Feld mit dem Primarty Key und Auto Increment heisst in der Regel immer <strong>id</strong> und ist an erster stelle! Damit eine Tabelle einen 
		eindeutigen Identifikator hat zum zu bearbeiten und l&ouml;schen ist eine <strong>id</strong> zwingend!
		</div></td>
	</tr>
	<tr>
		<td><input type="text" class="text" name="table" value="mod_" /></td>
	</tr>
	<tr>
		<td valign="top"><div id="frm_container"></div></td>
	</tr>
	<tr>
		<td><a href="javascript:DevMod.AddField()">Neues Feld Hinzuf&uuml;gen</a>
	</tr>
	<tr>
		<td><input type="submit" name="save" class="submit" value="Speichern" /></td>
	</tr>
	
</table>
</form>

{else}

	<h2>M&ouml;chtest du dieses Query nun ausf&uuml;hren?</h2>
	<pre>{$sql}</pre>
	<a class="submit" href="#" onclick="BkLoader.Get('&save=true').Load('mysql_mgr');">Speichern</a>

{/if}
</div>

{if count(tables) > 0}
<div class="block">
	{foreach from=$tables item=item key=key}
		<h2>{$key} <a href="#table_alter" onclick="new Effect.toggle('alter_{$key}', 'slide');"><img src="{$theme}img/add.gif" height="11" border="0" /></a></h2>
		<div id="alter_{$key}" style="display:none;">
			<form action="#" onsubmit="BkLoader.Post(this).Load('mysql_mgr'); return false;" method="post">
				<input type="hidden" name="action" value="alter_table" />
				<input type="hidden" name="table" value="{$key}" />
				<table>
					<tr>
						<td style="padding:0px;"><input type="text"  name="alt_name" value=""></td>
						<td>
							<select name="alt_type">
								<option value="INT">INT</option>
								<option value="VARCHAR (255)">VARCHAR (255)</option>
								<option value="TEXT">Text</option>
							</select>
						</td>
						<td>
							<input type="submit" class="submit" value="Hinzuf&uuml;gen" style="padding:1px;" />
						</td>
					</tr>
				</table>
			</form>
		</div>
		<table class="color_table">
		<tr>
			<td><strong>Name</strong></td>
			<td><strong>Type</strong></td>
			<td><strong>Keys</strong></td>
			<td><strong>Extras</strong></td>
		</tr>
			{foreach from=$item item=i}
			<tr>
				<td>{$i.Field}</td>
				<td>{$i.Type}</td>
				<td>{$i.Key}</td>
				<td>{$i.Extra}</td>
			</tr>
			{/foreach}
		</table>
	{/foreach}
</div>
{/if}